package com.rr;

import java.math.BigInteger;
import java.security.MessageDigest;

import javax.sound.sampled.AudioFormat.Encoding;

public class md5 {
	
	public static String getMD5(String str) {
	    try {
	        // 生成一个MD5加密计算摘要
	        MessageDigest md = MessageDigest.getInstance("MD5");
	        // 计算md5函数
	        md.update(str.getBytes());
	        // digest()最后确定返回md5 hash值，返回值为8为字符串。因为md5 hash值是16位的hex值，实际上就是8位的字符
	        // BigInteger函数则将8位的字符串转换成16位hex值，用字符串来表示；得到字符串形式的hash值
	        return new BigInteger(1, md.digest()).toString(16);
	    } catch (Exception e) {
	       System.out.println("error");
	       return "";
	    }
	}
	
	public static String strAdd(String str){
		
		str = "tplogin://" + str + "cmbtest1";
		return str;
	}
	
	 public static void main(String[] args) {
		 
		 //String str = "tt.7i1.cn/serverpay/wxpay/login.html?param=xxxxx&corpno=001064";
		 String str = "www.jx37.cn/api/weixin/receivebank.ashx?param=xxxxx&corpno=001064";
		 String str2 = strAdd(str);
		 String auth = getMD5(str2);
		 System.out.println("tplogin://" + str + "&auth=" + auth);
		 System.out.println("tplogin://tt.7i1.cn/serverpay/wxpay/login.html?param=xxxxx&corpno=001064&auth=46b08592892ba5766dc73330ee962ae2"
);
		 
		 String s = "amount=0.15&bankDate=20170320&bankSerialNo=17232061800000000010&branchNo=0755&cardType=02&date=20170320&dateTime=20170320173908&discountAmount=0.00&discountFlag=N&httpMethod=POST&merchantNo=000166&merchantPara=aaa¬iceSerialNo=0755000166201703200027486507¬iceType=BKPAYRTN¬iceUrl=http://183.16.190.163:8081/essayPost/login3&orderNo=0027486507";
		 s.replace("¬", "&not");
		 System.out.println(s);
	 }
	
	

}
